﻿/*****************************************介绍*****************************************
 * 作者：User
 * 创建时间：2025-06-18 16:12:21
 * 功能：点击效果：由大到小
**************************************************************************************/

using DG.Tweening;
using Game.Framework;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

[DisallowMultipleComponent]
public class ClickEffect_BigtoSmall : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
    private float m_BigSize = 1f;
    private float m_SimallSize = 0.8f;
    private float m_Duration = 0.15f;
    private Selectable m_Selectable;

    private void Awake()
    {
        m_Selectable = GetComponent<Selectable>();
    }

    public void OnPointerDown(PointerEventData eventData)
    {
        if (m_Selectable && !m_Selectable.interactable) return;
        if (GameDataMgr.Instance.VibrationSwitch)
            NativeInteraction.Instance.TriggerVibration(VibrationType.Soft);
        transform.DOScale(Vector3.one * m_SimallSize, m_Duration);
        AudioManager.Instance.PlayAudio("Audios/ClickOn");
    }

    public void OnPointerUp(PointerEventData eventData)
    {
        if (m_Selectable && !m_Selectable.interactable) return;
        transform.DOScale(Vector3.one * m_BigSize, m_Duration);
    }
}